<style type="text/css">
  .form-control {
    display: -webkit-inline-box;
    width: 30%;
  }
  label {
    width: 6%;
    text-align: right;
    margin-right: 10px;
  }
  input[type=file] {
    display: -webkit-inline-box;
  }
  .ct {
    margin-left: 6.8%;
  }
</style>
<br>
<div class="box box-primary">
  <div class="box-header with-border">
    <h3 class="box-title">新建</h3>
  </div>
  <!-- /.box-header -->
  <!-- form start -->
  <form id="theForm"  enctype="multipart/form-data">
    <div class="box-body">
      <div class="form-group">
        <label for="parents_id">NAME1</label>
        <span id="parents_id"></span>
      </div>
      <div class="form-group">
        <label for="business_name">NAME1</label>
        <input type="text" class="form-control" name="business_name" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="username">NAME1</label>
        <input type="text" class="form-control" name="username" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="password">NAME1</label>
        <input type="password" class="form-control" name="password" placeholder="描述" value="">
      </div>

      <div class="form-group">
        <label for="sales">NAME1</label>
        <input type="text" class="form-control" name="sales" placeholder="描述" value="">
      </div>

      <div class="form-group">
        <label for="mobile">NAME1</label>
        <input type="text" class="form-control" name="mobile" placeholder="描述" value="">
      </div>

      <div class="form-group">
        <label for="category_id">NAME1</label>
        <input type="text" class="form-control" name="category_id" placeholder="描述" value="">
      </div>

<!--       <div class="form-group">
        <label for="area_id">区域</label>
        <span id="area_id"></span>
      </div> -->
      <div class="form-group">
        <label for="address">NAME1</label>
        <input type="text" class="form-control" name="address" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="traffic">NAME1</label>
        <input type="text" class="form-control" name="traffic" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="longitude">NAME1</label>
        <input type="text" class="form-control" name="longitude" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="latitude">NAME1</label>
        <input type="text" class="form-control" name="latitude" placeholder="描述" value="">
      </div>

      <div class="form-group">
        <label for="description">NAME1</label>
        <input type="text" class="form-control" name="description" placeholder="描述" value="">
      </div>
      <div class="form-group">
        <label for="logo">图片</label>
        <input type="file" name="logo" id="logo" class="upload">
        <input type="input" id="picture" hidden="true" name="picture">
        <p class="help-block"></p>
      </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
      <div  class="btn btn-primary ct" onclick="createbusiness()">创建</div>
    </div>
  </form>
</div>
<script type="text/javascript">
  var field = "parents_id";
  var param = {};
  param.action = 'goods_list';
  param.bid    = window.localStorage.getItem("bid"); 
  param.token    = window.localStorage.getItem("token");
  commonAjax('getbusiness',5,field,param);

  // var field = "area_id";
  // commonAjax('getarea',5,field);

  function createbusiness()
  {
    var action = 'upload';
    var q = JSON.stringify(param);
    var sign = $.md5(q+safe_key);

    var formdata = new FormData($("#theForm")[0]);
    formdata.append('logo', $('#logo')[0].files[0]);
    formdata.append('q', q);
    formdata.append('sign', sign);

    var jumpurl = "businesslist";
    postFormDataAjax(action,formdata,jumpurl,Assignment=0);
  }

  $(".upload").change(function(){ 
    var action = 'upload';
    var q = JSON.stringify(param);
    var sign = $.md5(q+safe_key);


    var formdata = new FormData($("#theForm")[0]);
    formdata.append('logo', $('#logo')[0].files[0]);
    formdata.append('q', q);
    formdata.append('sign', sign);

    var Assignment = 'picture';
    postFormDataAjax(action,formdata,jumpurl=0,Assignment);
  });




</script>